package com.ihighest.app.infox.activity;

import java.util.Iterator;

import org.json.JSONArray;
import org.json.JSONException;

import android.annotation.SuppressLint;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Bundle;
import android.provider.Settings;
import android.provider.Settings.SettingNotFoundException;
import android.text.TextUtils;
import android.text.TextUtils.TruncateAt;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.MeasureSpec;
import android.view.View.OnClickListener;
import android.view.View.OnTouchListener;
import android.view.ViewGroup.LayoutParams;
import android.view.WindowManager;
import android.webkit.WebSettings.LayoutAlgorithm;
import android.webkit.WebSettings.RenderPriority;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.PopupWindow;
import android.widget.RadioGroup;
import android.widget.ScrollView;
import android.widget.SeekBar;
import android.widget.SeekBar.OnSeekBarChangeListener;
import android.widget.TextView;

import com.baidu.mapapi.map.Text;
import com.ihighest.app.common.api.Api;
import com.ihighest.app.common.api.ApiCallback;
import com.ihighest.app.common.api.ApiParam;
import com.ihighest.app.common.api.ApiResult;
import com.ihighest.app.common.api.EmptyApiCallback;
import com.ihighest.app.common.kit.AppKit;
import com.ihighest.app.common.kit.ListViewKit;
import com.ihighest.app.common.kit.SharedPreferencesKit;
import com.ihighest.app.common.kit.ToastKit;
import com.ihighest.app.common.kit.WebInvoker;
import com.ihighest.app.infox.Const;
import com.ihighest.app.infox.R;
import com.ihighest.app.infox.adapter.CommentAdapter;
import com.ihighest.app.infox.adapter.RelatedReadingListViewAdapter;
import com.ihighest.app.infox.myview.AKListView;
import com.ihighest.app.infox.myview.ActivityTitle;
import com.ihighest.app.infox.tools.InitShare;
import com.ihighest.app.infox.tools.LongTimeForData;
import com.umeng.socialize.bean.SHARE_MEDIA;

/**
 * 资讯内容界面
 * 
 * @author lkx Created at 2015-10-12 下午5:40:43
 * @version 1.0
 */
public class InformationalContentActivity extends BaseActivity implements OnClickListener {
	final static String TAG = "InformationalContentActivity";
	private ActivityTitle title;
	private WebView webView;
	private PopupWindow mPopupWindow;
	private EditText writeComment;
	private ScrollView scrollview;
	private String newsId;// 内容id
	private TextView mTitle, mCome, mData;
	private String contentTitle;
	private String contentCome;
	private String contentData, content;
	private ListView relatedReadinglistView;
	private SHARE_MEDIA shareTo;
	private TextView writerTextView;
	// 标签
	private TextView[] dots;
	private String type;
	private ImageView lookComment;
	private ListView newCommentListview;
	private ListView hotListview;
	private FrameLayout lookCommentlayout;
	private TextView careContent;
	private ImageView collection;
	private TextView commentCount;
	private String categoryId;
	private String action = "";// 收藏action
	private String careAction = "";
	private InitShare share;
	private SHARE_MEDIA commentAndShare;// 评论时的分享
	private int beCaredNumber;// 已经关心的数量
	private CheckBox weixinShare, friendCirclrShare;// 快捷的微信个朋友分享
	private TextView noHotCommentData, noNewCommentData;
	private String shareId;
	private Boolean isSub = false;
	View RelatedReadingTitle, imageView2, imageView1;
	LinearLayout lableLauput;// 标签
	AKListView lingkListview;// 相关阅读
	String fontSize;
	String url;
	private CommentAdapter commentAdapter;
	private JSONArray hotCommentArray;
	private JSONArray newCommentArray;
	private JSONArray newMoreCommentArray;
	private CommentAdapter newCommentAdapter;
	final String INVOKER_JS_SHOW_IMAGE = "<script>function INFOX_showImage(){window.Invoker.showImage(this.src)};for(var i= 0; i < document.images.length; i++){document.images[i].addEventListener('click',INFOX_showImage , false);}</script>";

	boolean isFirstLoading = true;
	int page = 1;
	private long time;

	long TEST_TIME;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.infox_activity_informational_content);
		newsId = getIntent().getStringExtra("newsId");

		initView();
		if (getIntent().getStringExtra("from") != null && getIntent().getStringExtra("from").equals("cloumn")) {
			// show
			
			showname.setText("专栏号/" + getIntent().getStringExtra("clumname"));
			isSub = getIntent().getBooleanExtra("isSubscribes", false);
              final String clumid=getIntent().getStringExtra("clumid");
			if (isSub) {
				isSubscribes.setText("已订阅");
			} else {
				isSubscribes.setText("订阅");
			}

		linear.setVisibility(View.VISIBLE);
		isSubscribes.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				if(isSub){
					submit("2",clumid);
				}else{
					submit("1",clumid);
				}
			}
		});
		showname.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				Intent intent=new Intent(InformationalContentActivity.this,ColumnNameActivity.class);
				intent.putExtra("cid", clumid);
				startActivity(intent);
			}
		});
		}
		initData(newsId);

	}
    
	
	protected void submit(final String type,String clumid) {
		Api.post("me/followColumnist", ApiParam.create().addParam("id", clumid).addParam("type", type), new ApiCallback(this, true) {

			@Override
			public void handleSuccess(ApiResult result) {
				if (result.getCode() == 100) {
					if (type.equals("1")) {
						isSubscribes.setText("已订阅");
						ToastKit.showShort(getApplicationContext(),"已订阅");
						isSub=true;
					} else {
						isSubscribes.setText("订阅");
						ToastKit.showShort(getApplicationContext(),"已取消");
						isSub=false;
					}
					
				}
			}

			@Override
			public void handleFailure(Exception e, String msg) {
				if (TextUtils.isEmpty(SharedPreferencesKit.getString(InformationalContentActivity.this, Const.SP_KEY_USER_ID))) {
					Intent intent = new Intent(InformationalContentActivity.this, LoginActivity.class);
					ToastKit.showShort(getApplicationContext(),Const.UN_LOGIN_ALERT);
					startActivity(intent);
				} else { 
					ToastKit.showShort(getApplicationContext(),"操作失败，稍后重试");
				}
			}
		}, this);

	}
	
	/**
	 * 动态获取信息
	 * 
	 * @author lkx Created at 2015-10-22 下午2:09:48
	 */
	private void getContentData() {
		Api.get("content", ApiParam.create().addParam("id", newsId).addParam("type", type), new ApiCallback(
				InformationalContentActivity.this, true) {

			@Override
			public void handleSuccess(ApiResult result) {
				try {
					if (result.getData().getInt("commonts") != 0) {
						commentCount.setVisibility(View.VISIBLE);
					}
					beCaredNumber = result.getData().getInt("cares");
					commentCount.setText(result.getData().getInt("commonts") + "");
					careContent.setText(result.getData().getInt("cares") + "");
					// 是否关心，推广数据
					if (result.getData().getBoolean("care")) {
						careAction = "1";
						Drawable drawable = getResources().getDrawable(R.drawable.infox_content_care_press);
						// / 这一步必须要做,否则不会显示.
						drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
						careContent.setCompoundDrawables(drawable, null, null, null);
						careContent.setBackgroundResource(R.drawable.infox_content_care_bg_press);
					}
					if (result.getData().getBoolean("fav")) {
						action = "1";
						collection.setImageResource(R.drawable.infox_content_collection_perss);
					}
				} catch (JSONException e) {
					e.printStackTrace();
				}

			}

			@Override
			public void handleFailure(Exception e, String msg) {

			}
		}, InformationalContentActivity.this);
		/**
		 * 加载栏目配置信息
		 */
		String mUrl = "categoryConfig/" + categoryId + ".json";
		Api.data(mUrl, new ApiCallback(InformationalContentActivity.this, true) {

			@Override
			public void handleSuccess(ApiResult result) {
				SharedPreferencesKit.putJsonObject(InformationalContentActivity.this, Const.CategoryConfig, result.getData());
			}

			@Override
			public void handleFailure(Exception e, String msg) {
			}
		}, InformationalContentActivity.this);
		getCommentData();
	}

	/**
	 * 初始化数据
	 * 
	 * @author lkx Created at 2015-10-20 下午3:08:05
	 */
	private void initData(String id) {
		/**
		 * 加载文章内容
		 */
		TEST_TIME = System.currentTimeMillis();
		Api.data("content/" + id + ".json", new ApiCallback(InformationalContentActivity.this) {
			String writer = "";

			@Override
			public void handleSuccess(ApiResult result) {
				Log.d(TAG, "加载成功：" + (System.currentTimeMillis() - TEST_TIME));

				isFirstLoading = false;
				try {
					for (Iterator iterator = result.getData().keys(); iterator.hasNext();) {
						if (iterator.next().toString().equals("writer")) {
							writer = result.getData().getString("writer");
						}
					}

					contentCome = result.getData().getString("source");
					contentTitle = result.getData().getString("title");
					contentData = LongTimeForData.transferLongToDate(result.getData().getLong("time"));
					content = result.getData().getString("content");
					type = result.getData().getString("type");
					categoryId = result.getData().getString("categoryId");
					// String writer= result.getData().getString("writer");
					mTitle.setText(contentTitle);
					mCome.setText(contentCome);
					mData.setText(contentData);
					if (!TextUtils.isEmpty(writer)) {
						writerTextView.setText("作者：" + writer);
					}
					Log.d(TAG, "UI渲染成功：" + (System.currentTimeMillis() - TEST_TIME));
					renderWebView();
					initLable(result.getData().getJSONArray("tags"));
					inintlistview(result.getData().getJSONArray("links"));
					getContentData();
					url = "http://info.nzdb.com.cn/app";
					if (!TextUtils.isEmpty(SharedPreferencesKit.getString(InformationalContentActivity.this, Const.SP_KEY_USER_ID))) {
						try {
							url = SharedPreferencesKit.getJsonObject(InformationalContentActivity.this, Const.SP_KEY_CONFIG_JSON)
									.getString("downAppUrl")
									+ "?code="
									+ SharedPreferencesKit.getString(InformationalContentActivity.this, Const.USER_InvitedCode)
									+ "&mid="
									+ SharedPreferencesKit.getString(InformationalContentActivity.this, Const.SP_KEY_USER_MID);

						} catch (Exception e) {
							Log.e(TAG, e.getMessage(), e);
						}

					}

				} catch (JSONException e) {
					Log.e(TAG, e.getMessage(), e);
				}
			}

			@Override
			public void handleFailure(Exception e, String msg) {

			}
		}, InformationalContentActivity.this);
		if (!TextUtils.isEmpty(SharedPreferencesKit.getString(InformationalContentActivity.this, Const.SP_KEY_USER_ID))) {

			Api.get("share", ApiParam.create().addParam("dataId", id).addParam("type", "InformationNews"), new ApiCallback(
					InformationalContentActivity.this) {
				@Override
				public void handleFailure(Exception e, String msg) {
				}

				@Override
				public void handleSuccess(ApiResult result) {
					try {
						shareId = result.getData().getString("ShareId");
					} catch (JSONException e1) {
						// TODO Auto-generated catch block
						e1.printStackTrace();
					}
					try {
						url = SharedPreferencesKit.getJsonObject(InformationalContentActivity.this, Const.SP_KEY_CONFIG_JSON).getString(
								"downAppUrl")
								+ "?code="
								+ SharedPreferencesKit.getString(InformationalContentActivity.this, Const.USER_InvitedCode)
								+ "&mid="
								+ SharedPreferencesKit.getString(InformationalContentActivity.this, Const.SP_KEY_USER_MID)
								+ "&ShareId=" + shareId;
					} catch (Exception e) {
						Log.e(TAG, e.getMessage(), e);
					}
				}
			}, InformationalContentActivity.this);
		}
	}

	/**
	 * 渲染web页面
	 * 
	 * @param content
	 * @author Vity Created at 2015-11-1 下午9:31:06
	 */
	void renderWebView() {
		fontSize = SharedPreferencesKit.getString(this, Const.SP_TEXTSIZE, "mid");
		String html = null;
		String colorCss = null;

		if (SharedPreferencesKit.getBoolean(InformationalContentActivity.this, Const.SP_NIGHTStyle, false)) {
			colorCss = "<style type='text/css'>* { text-indent:1em;background-color: #262626;color: #999999;} img{width:98% !important;  height:auto !important; display:block; margin:0 auto;} </style> ";
		} else {
			colorCss = "<style type='text/css'>* {text-indent:1em; background-color: #fff;color: #333;} img{width:98% !important; height:auto !important; display:block; margin:0 auto;} </style> ";
		}

		if ("max_big".equalsIgnoreCase(fontSize)) {
			html = "<meta name='viewport' content='width=device-width,initial-scale=1.0,user-scalable=no'/> <style type='text/css'>* { font-size: 24px; line-height: 32px; letter-spacing:1px;	} </style>  "
					+ colorCss + content;
		} else if ("mid".equalsIgnoreCase(fontSize)) {
			html = "<meta name='viewport' content='width=device-width,initial-scale=1.0,user-scalable=no'/> <style type='text/css'>* { font-size: 16px; line-height: 24px; letter-spacing:1px;	} </style>  "
					+ colorCss + content;
		} else if ("min".equalsIgnoreCase(fontSize)) {
			html = "<meta name='viewport' content='width=device-width,initial-scale=1.0,user-scalable=no'/> <style type='text/css'>* { font-size: 12px; line-height: 20px; letter-spacing:1px;	} </style>  "
					+ colorCss + content;
		} else if ("max".equalsIgnoreCase(fontSize)) {
			html = "<meta name='viewport' content='width=device-width,initial-scale=1.0,user-scalable=no'/> <style type='text/css'>* { font-size: 20px; line-height: 28px; letter-spacing:1px;	} </style>  "
					+ colorCss + content;

		}
		webView.loadDataWithBaseURL(null, html + INVOKER_JS_SHOW_IMAGE, "text/html", "utf-8", null);
	}

	/**
	 * 获取评论数据
	 * 
	 * @author lkx Created at 2015-10-22 下午4:40:16
	 */
	private void getCommentData() {
		/**
		 * 热门评论获取
		 */
		Api.get("comment/infos", ApiParam.create().addParam("id", newsId).addParam("sort", "hot").addParam("page", "1"), new ApiCallback(
				InformationalContentActivity.this, true) {

			@Override
			public void handleSuccess(ApiResult result) {
				final JSONArray array = result.getDatas();
				if (result.getDatas().length() != 0) {
					noHotCommentData.setVisibility(View.GONE);
					// hotCommentLayout.setVisibility(View.VISIBLE);
					hotListview.setVisibility(View.VISIBLE);
					hotCommentArray = result.getDatas();
					commentAdapter = new CommentAdapter(InformationalContentActivity.this, result.getDatas());
					hotListview.setAdapter(new CommentAdapter(InformationalContentActivity.this, result.getDatas()));
					ListViewKit.setListViewHeightBasedOnChildren(hotListview);
				} else {
					noHotCommentData.setVisibility(View.VISIBLE);
					// hotCommentLayout.setVisibility(View.GONE);
					hotListview.setVisibility(View.GONE);
				}
				hotListview.setOnItemClickListener(new OnItemClickListener() {

					@Override
					public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
						try {
							Intent intent = new Intent(InformationalContentActivity.this, CommentDetailsActivity.class);
							intent.putExtra("id", array.getJSONObject(position).getString("id"));
							intent.putExtra("commentName", array.getJSONObject(position).getString("name"));
							intent.putExtra("commentImg", array.getJSONObject(position).getString("image"));
							intent.putExtra("commentContent", array.getJSONObject(position).getString("content"));
							intent.putExtra("praises", array.getJSONObject(position).getInt("praises"));
							intent.putExtra("commentTime", array.getJSONObject(position).getLong("time"));
							intent.putExtra("commentsReply", array.getJSONObject(position).getInt("comments"));
							startActivity(intent);
						} catch (JSONException e) {
							Log.e(TAG, e.getMessage(), e);
						}
					}
				});
			}

			@Override
			public void handleFailure(Exception e, String msg) {
			}
		}, InformationalContentActivity.this);

		getNewComment();
	}

	boolean isNewCommontLoading = false;
	private LinearLayout linear;
	private TextView showname;
	private TextView isSubscribes;

	/**
	 * 获取最新评论
	 * 
	 * @author lkx Created at 2015-11-6 下午9:33:44
	 */
	private void getNewComment() {
		ApiParam param = ApiParam.create();
		param.addParam("id", newsId).addParam("sort", "new").addParam("page", page);
		if (page >= 2) {
			param.addParam("time", time);
		}
		if (isNewCommontLoading) {
			page--;
			return;
		}
		isNewCommontLoading = true;
		Api.get("comment/infos", param, new ApiCallback(InformationalContentActivity.this, true) {

			@Override
			public void handleSuccess(ApiResult result) {
				if (result.getDatas().length() != 0) {
					noNewCommentData.setVisibility(View.GONE);
					newCommentListview.setVisibility(View.VISIBLE);
					if (page == 1) {
						newCommentArray = result.getDatas();

						newCommentAdapter = new CommentAdapter(InformationalContentActivity.this, result.getDatas());
						newCommentListview.setAdapter(newCommentAdapter);
					} else {
						newMoreCommentArray = result.getDatas();
						try {
							newCommentArray = AppKit.joinJSONArray(newCommentArray, newMoreCommentArray);
						} catch (JSONException e) {
						}
						newCommentAdapter.appendData(newMoreCommentArray);
						time = result.getTime();
					}

					ListViewKit.setListViewHeightBasedOnChildren(newCommentListview);
				} else {
					if (page == 1) {
						noNewCommentData.setVisibility(View.VISIBLE);
						// newCommentLayout.setVisibility(View.GONE);
						newCommentListview.setVisibility(View.GONE);
					} else {
						page = page > 1 ? --page : 1;
					}

				}
				newCommentListview.setOnItemClickListener(new OnItemClickListener() {

					@Override
					public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
						try {
							Intent intent = new Intent(InformationalContentActivity.this, CommentDetailsActivity.class);
							intent.putExtra("id", newCommentArray.getJSONObject(position).getString("id"));
							intent.putExtra("commentName", newCommentArray.getJSONObject(position).getString("name"));
							intent.putExtra("commentImg", newCommentArray.getJSONObject(position).getString("image"));
							intent.putExtra("commentContent", newCommentArray.getJSONObject(position).getString("content"));
							intent.putExtra("praises", newCommentArray.getJSONObject(position).getInt("praises"));
							intent.putExtra("commentTime", newCommentArray.getJSONObject(position).getLong("time"));
							intent.putExtra("commentsReply", newCommentArray.getJSONObject(position).getInt("comments"));
							startActivity(intent);
						} catch (JSONException e) {
							Log.e(TAG, e.getMessage(), e);
						}
					}
				});
				isNewCommontLoading = false;
			}

			@Override
			public void handleFailure(Exception e, String msg) {
				isNewCommontLoading = false;
			}
		}, InformationalContentActivity.this);
	}

	/**
	 * 设置相关阅读数据
	 * 
	 * @param jsonArray
	 * @author lkx Created at 2015-10-21 下午5:19:34
	 */
	private void inintlistview(JSONArray jsonArray) {
		if (jsonArray != null && jsonArray.length() > 0) {
			RelatedReadingTitle.setVisibility(View.VISIBLE);
			imageView2.setVisibility(View.VISIBLE);
			imageView1.setVisibility(View.VISIBLE);
			RelatedReadingListViewAdapter adapter = new RelatedReadingListViewAdapter(this);
			relatedReadinglistView.setAdapter(adapter);
			adapter.setDatas(jsonArray);
			ListViewKit.setListViewHeightBasedOnChildren(relatedReadinglistView);
		} else {
			lingkListview.setVisibility(View.GONE);
			// RelatedReadingTitle.setVisibility(View.GONE);
			imageView2.setVisibility(View.GONE);
			imageView1.setVisibility(View.GONE);
		}
	}

	/**
	 * 初始化文章相关标签
	 * 
	 * @author lkx Created at 2015-10-21 下午2:20:57
	 */
	private void initLable(final JSONArray lableArray) {
		if (lableArray != null && lableArray.length() > 0) {

			LinearLayout.LayoutParams mParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
			dots = new TextView[lableArray.length()];
			LinearLayout layout = (LinearLayout) findViewById(R.id.lableLinearLayout);
			layout.removeAllViews();
			lableLauput.setVisibility(View.VISIBLE);
			for (int i = 0; i < lableArray.length(); i++) {
				dots[i] = new TextView(InformationalContentActivity.this);
				dots[i].setBackgroundResource(R.drawable.infox_information_plantbg);
				try {
					dots[i].setText(lableArray.getJSONObject(i).getString("title"));
				} catch (JSONException e) {
					Log.e(TAG, e.getMessage(), e);
				}
				mParams.leftMargin = 5;
				mParams.rightMargin = 5;
				dots[i].setGravity(Gravity.CENTER);
				dots[i].setEllipsize(TruncateAt.END);
				dots[i].setSingleLine(true);
				dots[i].setTextSize(14f);
				dots[i].setPadding(5, 2, 5, 2);
				dots[i].setTextColor(getResources().getColor(R.color.lable_color));
				layout.addView(dots[i], mParams);
				dots[i].setOnClickListener(new OnClickListener() {
					@Override
					public void onClick(View arg0) {
						Intent intent = new Intent(InformationalContentActivity.this, SearchResultActivity.class);
						intent.putExtra("key", ((TextView) arg0).getText());
						startActivity(intent);
					}
				});
			}
		} else {
			lableLauput.setVisibility(View.GONE);
		}
	}

	/**
	 * 初始化绑定
	 * 
	 * @author lkx Created at 2015-10-12 下午5:42:33
	 */
	@SuppressLint({ "JavascriptInterface", "SetJavaScriptEnabled" })
	private void initView() {
		share = new InitShare(InformationalContentActivity.this);
		title = (ActivityTitle) findViewById(R.id.InformationalContentActivityTitle);
		title.setViewVersible(title.titleBack);
		title.setViewGone(title.titleMsg, title.titleRefresh, title.rightLayout, title.top_title_text);
		scrollview = (ScrollView) findViewById(R.id.contentScrollView);
		findViewById(R.id.waitComment).setOnClickListener(this);
		findViewById(R.id.lookComment).setOnClickListener(this);
		collection = (ImageView) findViewById(R.id.collectionContent);
		collection.setOnClickListener(this);
		findViewById(R.id.shareContentLayout).setOnClickListener(this);
		findViewById(R.id.changeContentTextsizeLayout).setOnClickListener(this);
		findViewById(R.id.contentReportLayout).setOnClickListener(this);
		noHotCommentData = (TextView) findViewById(R.id.noHotCommentData);
		noNewCommentData = (TextView) findViewById(R.id.noNewCommentData);
		mTitle = (TextView) findViewById(R.id.contentTitle);
		// mTitle.setTextSize(SharedPreferencesKit.getFloat(getApplicationContext(),
		// Const.SP_TEXTSIZE));
		mCome = (TextView) findViewById(R.id.contentFrom);
		mData = (TextView) findViewById(R.id.contentDate);
		writerTextView = (TextView) findViewById(R.id.writer);
		webView = (WebView) findViewById(R.id.contentView);

		linear = (LinearLayout) findViewById(R.id.id_linear);
		showname = (TextView) findViewById(R.id.id_showname);
		isSubscribes = (TextView) findViewById(R.id.id_isSubscribes);

		lableLauput = (LinearLayout) findViewById(R.id.lableLinearLayout);
		lingkListview = (AKListView) findViewById(R.id.relatedReadinglistView);
		// webView.getSettings().setTextSize();

		careContent = (TextView) findViewById(R.id.careCount);
		commentCount = (TextView) findViewById(R.id.commentCOunt);
		lookComment = (ImageView) findViewById(R.id.lookComment);
		lookComment.setOnClickListener(this);
		relatedReadinglistView = (ListView) findViewById(R.id.relatedReadinglistView);
		RelatedReadingTitle = findViewById(R.id.RelatedReadingTitle);
		imageView2 = findViewById(R.id.imageView2);
		imageView1 = findViewById(R.id.imageView1);
		newCommentListview = (ListView) findViewById(R.id.newCommenListview);
		hotListview = (ListView) findViewById(R.id.hotCommenListview);
		lookCommentlayout = (FrameLayout) findViewById(R.id.id_lookCommentlayout);
		weixinShare = (CheckBox) findViewById(R.id.weixin);
		friendCirclrShare = (CheckBox) findViewById(R.id.friendCircle);
		lookCommentlayout.setOnClickListener(this);
		// 支持javascript
		webView.getSettings().setJavaScriptEnabled(true);
		webView.addJavascriptInterface(new WebInvoker(this), "Invoker");
		webView.getSettings().setBuiltInZoomControls(false);
		// 设置可以支持缩放
		webView.getSettings().setSupportZoom(false);
		webView.getSettings().setRenderPriority(RenderPriority.HIGH);
		webView.getSettings().setBlockNetworkImage(true);
		// if (android.os.Build.VERSION.SDK_INT > 11) {
		// webView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
		// }
		// webView.getSettings().setLoadWithOverviewMode(true);
		// webView.getSettings().setSupportMultipleWindows(true);
		// 自适应屏幕
		webView.getSettings().setLayoutAlgorithm(LayoutAlgorithm.SINGLE_COLUMN);

		webView.setWebViewClient(new WebViewClient() {

			@Override
			public boolean shouldOverrideUrlLoading(WebView view, String url) {
				view.loadUrl(url);
				return true;
			}

			@Override
			public void onPageStarted(WebView view, String url, Bitmap favicon) {
				Log.d(TAG, "onPageStarted：" + (System.currentTimeMillis() - TEST_TIME));
				super.onPageStarted(view, url, favicon);
			}

			@Override
			public void onPageFinished(WebView view, String url) {
				view.getSettings().setBlockNetworkImage(false);
				Log.d(TAG, "PageFinished：" + (System.currentTimeMillis() - TEST_TIME));
				super.onPageFinished(view, url);
			}
		});
		webView.setOnTouchListener(new OnTouchListener() {
			@Override
			public boolean onTouch(View v, MotionEvent event) {
				// if (event.getAction() == MotionEvent.ACTION_UP)
				// if (webView.getContentHeight() * webView.getScale() -
				// (webView.getHeight() + webView.getScrollY()) == 0) {
				// // 已经处于底端
				// scrollview.requestDisallowInterceptTouchEvent(true);
				// } else {
				// scrollview.requestDisallowInterceptTouchEvent(false);
				// }
				//
				// else

				scrollview.requestDisallowInterceptTouchEvent(false);
				return false;
			}
		});
		careContent.setOnClickListener(new OnClickListener() {

			@SuppressWarnings("deprecation")
			@Override
			public void onClick(View arg0) {
				if (TextUtils.isEmpty(SharedPreferencesKit.getString(InformationalContentActivity.this, Const.SP_KEY_USER_ID))) {
					Intent intent = new Intent(InformationalContentActivity.this, LoginActivity.class);
					ToastKit.showShort(InformationalContentActivity.this, Const.UN_LOGIN_ALERT);
					startActivity(intent);
				} else {
					ApiParam param = ApiParam.create();
					param.addParam("id", newsId);
					param.addParam("type", type);
					if (careAction.equals("1")) {
						careAction = "2";
						Drawable drawable = getResources().getDrawable(R.drawable.infox_content_care_noraml);
						// / 这一步必须要做,否则不会显示.
						drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
						careContent.setCompoundDrawables(drawable, null, null, null);
						careContent.setBackgroundResource(R.drawable.infox_content_care_bg);
						param.addParam("action", "2");
						beCaredNumber--;
						careContent.setText(beCaredNumber + "");
					} else {
						careAction = "1";
						Drawable drawable = getResources().getDrawable(R.drawable.infox_content_care_press);
						// / 这一步必须要做,否则不会显示.
						drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
						careContent.setCompoundDrawables(drawable, null, null, null);
						careContent.setBackgroundResource(R.drawable.infox_content_care_bg_press);
						param.addParam("action", "1");
						beCaredNumber++;
						careContent.setText(beCaredNumber + "");
					}
					commitCareAndCollection("me/care", param);

				}
			}
		});
		weixinShare.setOnCheckedChangeListener(new OnCheckedChangeListener() {

			@Override
			public void onCheckedChanged(CompoundButton arg0, boolean arg1) {
				if (arg1) {
					// 设置分享内容
					share.setMyShareContent(contentTitle, url);
					// 设置分享平台
					share.isShareSuccess(SHARE_MEDIA.WEIXIN);
				}
			}
		});
		friendCirclrShare.setOnCheckedChangeListener(new OnCheckedChangeListener() {

			@Override
			public void onCheckedChanged(CompoundButton arg0, boolean arg1) {
				if (arg1) {
					share.isShareSuccess(SHARE_MEDIA.WEIXIN_CIRCLE);
				}
			}
		});
		scrollview.setOnTouchListener(new TouchListenerImpl());
	}

	@Override
	public void onClick(View view) {
		switch (view.getId()) {
		case R.id.waitComment:
			initCommentPupoVindow();
			showPupop();
			break;
		case R.id.lookComment:
		case R.id.id_lookCommentlayout:
			scrollview.measure(MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED),
					MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
			if (scrollview.getScrollY() < scrollview.getMeasuredHeight() - hotListview.getMeasuredHeight()
					- newCommentListview.getMeasuredHeight()) {
				scrollview.scrollTo(0,
						scrollview.getMeasuredHeight() - hotListview.getMeasuredHeight() - newCommentListview.getMeasuredHeight());
			} else {
				scrollview.fullScroll(ScrollView.FOCUS_UP);
			}

			break;
		case R.id.collectionContent:
			if (TextUtils.isEmpty(SharedPreferencesKit.getString(InformationalContentActivity.this, Const.SP_KEY_USER_ID))) {
				Intent intent = new Intent(InformationalContentActivity.this, LoginActivity.class);
				ToastKit.showShort(InformationalContentActivity.this, Const.UN_LOGIN_ALERT);
				startActivity(intent);
			} else {
				ApiParam param = ApiParam.create();

				param.addParam("id", newsId);
				param.addParam("type", type);
				if (action.equals("1")) {
					action = "2";
					collection.setImageResource(R.drawable.infox_content_collection);
					param.addParam("action", "2");
				} else {
					action = "1";
					collection.setImageResource(R.drawable.infox_content_collection_perss);
					param.addParam("action", "1");
				}
				commitCareAndCollection("me/favorite", param);
			}
			break;
		case R.id.shareContentLayout:
			initSharePupoVindow();
			showPupop();
			break;
		case R.id.changeContentTextsizeLayout:
			initCotentSizePupoVindow();
			showPupop();
			break;
		case R.id.contentReportLayout:
			Intent intent = new Intent(InformationalContentActivity.this, ReportActivity.class);
			intent.putExtra("newsId", newsId);
			intent.putExtra("newType", type);
			startActivity(intent);
			break;
		// case R.id.careCount:
		// if
		// (TextUtils.isEmpty(SharedPreferencesKit.getString(InformationalContentActivity.this,
		// Const.SP_KEY_USER_ID))) {
		// Intent intent1 = new Intent(InformationalContentActivity.this,
		// LoginActivity.class);
		// startActivity(intent1);
		// } else {
		// ApiParam param = ApiParam.create();
		//
		// param.addParam("id", newsId);
		// param.addParam("type", type);
		// if (careAction.equals("1")) {
		// careAction = "2";
		// @SuppressWarnings("deprecation")
		// Drawable drawable =
		// getResources().getDrawable(R.drawable.infox_content_care_noraml);
		// // / 这一步必须要做,否则不会显示.
		// drawable.setBounds(0, 0, drawable.getMinimumWidth(),
		// drawable.getMinimumHeight());
		// careContent.setCompoundDrawables(drawable, null, null, null);
		// careContent.setBackgroundResource(R.drawable.infox_content_care_bg);
		// param.addParam("action", "2");
		// beCaredNumber--;
		// careContent.setText(beCaredNumber + "");
		// } else {
		// careAction = "1";
		// @SuppressWarnings("deprecation")
		// Drawable drawable =
		// getResources().getDrawable(R.drawable.infox_content_care_press);
		// // / 这一步必须要做,否则不会显示.
		// drawable.setBounds(0, 0, drawable.getMinimumWidth(),
		// drawable.getMinimumHeight());
		// careContent.setCompoundDrawables(drawable, null, null, null);
		// careContent.setBackgroundResource(R.drawable.infox_question_add);
		// param.addParam("action", "1");
		// beCaredNumber++;
		// careContent.setText(beCaredNumber + "");
		// }
		// commitCareAndCollection("me/care", param);
		// }
		// break;

		case R.id.shareToWeixin:
			shareTo = SHARE_MEDIA.WEIXIN;
			share.setMyShareContent(contentTitle, url);
			share.isShareSuccess(shareTo);
			break;
		case R.id.shareToFriendCircle:
			shareTo = SHARE_MEDIA.WEIXIN_CIRCLE;
			share.setMyShareContent(contentTitle, url);

			share.isShareSuccess(shareTo);
			break;
		case R.id.shareToMessage:
			shareTo = SHARE_MEDIA.SMS;
			share.setMyShareContent(contentTitle, url);
			share.isShareSuccess(shareTo);
			break;
		case R.id.shareToQQ:
			shareTo = SHARE_MEDIA.QQ;
			share.setMyShareContent(contentTitle, url);

			share.isShareSuccess(shareTo);
			break;
		case R.id.shareToWeb:
			shareTo = SHARE_MEDIA.SINA;
			share.setMyShareContent(contentTitle, url);
			share.isShareSuccess(shareTo);
			break;
		case R.id.shareEmail:
			shareTo = SHARE_MEDIA.EMAIL;
			share.setMyShareContent(contentTitle, url);
			share.isShareSuccess(shareTo);
			break;
		case R.id.transpond:
			ToastKit.showShort(InformationalContentActivity.this, Const.UN_FINISH_ALERT);
			break;
		case R.id.shareCopyLink:

			ClipboardManager clip = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
			if (Build.VERSION.SDK_INT >= 11) {
				ClipData clipData = ClipData.newPlainText("App下载链接", url);
				clip.setPrimaryClip(clipData);
			} else {
				clip.setText(url);
			}
			break;
		case R.id.cancle:
			mPopupWindow.dismiss();
			break;

		}

	}

	/**
	 * 提交关心和收藏
	 * 
	 * @param param
	 * @author lkx Created at 2015-10-22 下午7:41:04
	 */
	private void commitCareAndCollection(String url, ApiParam param) {
		Api.get(url, param, new ApiCallback(InformationalContentActivity.this, true) {

			@Override
			public void handleSuccess(ApiResult result) {

			}

			@Override
			public void handleFailure(Exception e, String msg) {
			}
		}, InformationalContentActivity.this);
	}

	/**
	 * 初始化评论popuwindow
	 * 
	 * @author lkx Created at 2015-10-5 上午10:58:08
	 */
	private void initCommentPupoVindow() {
		// final InitShare share = new
		// InitShare(InformationalContentActivity.this);
		LayoutInflater layoutInflater = LayoutInflater.from(this);
		View popupWindow = layoutInflater.inflate(R.layout.infox_content_waitcontent_pupo, null);
		CheckBox shareweixin = (CheckBox) popupWindow.findViewById(R.id.shareToWeixin);
		CheckBox shareFriendCircle = (CheckBox) popupWindow.findViewById(R.id.shareToFriendCircle);
		CheckBox shareQQ = (CheckBox) popupWindow.findViewById(R.id.shareToQQ);
		CheckBox shareWeb = (CheckBox) popupWindow.findViewById(R.id.shareToWeb);
		TextView commentCommit = (TextView) popupWindow.findViewById(R.id.commentCommit);
		writeComment = (EditText) popupWindow.findViewById(R.id.writeComment);
		shareweixin.setOnCheckedChangeListener(new OnCheckedChangeListener() {

			@Override
			public void onCheckedChanged(CompoundButton bux, boolean inscheck) {
				if (inscheck) {
					// share.setShareContent(writeComment.getText().toString(),
					// "http://www.baidu.com");
					commentAndShare = SHARE_MEDIA.WEIXIN;
					// share.isShareSuccess(SHARE_MEDIA.WEIXIN);
				} else {
					commentAndShare = null;
				}

			}
		});
		shareFriendCircle.setOnCheckedChangeListener(new OnCheckedChangeListener() {

			@Override
			public void onCheckedChanged(CompoundButton arg0, boolean isCheck) {
				if (isCheck) {
					// share.setShareContent(writeComment.getText().toString(),
					// "http://www.baidu.com");
					commentAndShare = SHARE_MEDIA.WEIXIN_CIRCLE;
					// share.isShareSuccess(SHARE_MEDIA.WEIXIN_CIRCLE);
				} else {
					commentAndShare = null;
				}

			}
		});
		shareQQ.setOnCheckedChangeListener(new OnCheckedChangeListener() {

			@Override
			public void onCheckedChanged(CompoundButton arg0, boolean isCheck) {
				if (isCheck) {
					// share.setShareContent(writeComment.getText().toString(),
					// "http://www.baidu.com");
					commentAndShare = SHARE_MEDIA.QQ;
					// share.isShareSuccess(SHARE_MEDIA.QQ);
				} else {
					commentAndShare = null;
				}

			}
		});
		shareWeb.setOnCheckedChangeListener(new OnCheckedChangeListener() {

			@Override
			public void onCheckedChanged(CompoundButton arg0, boolean isCheck) {
				if (isCheck) {
					// share.setShareContent(writeComment.getText().toString(),
					// "http://www.baidu.com");
					commentAndShare = SHARE_MEDIA.SINA;
					// share.isShareSuccess(SHARE_MEDIA.SINA);
				} else {
					commentAndShare = null;
				}

			}
		});
		commentCommit.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {
				if (commentAndShare != null) {
					share.setMyShareContent(writeComment.getText().toString() + contentTitle, url);
					share.isShareSuccess(commentAndShare);
				}
				try {
					if (SharedPreferencesKit.getJsonObject(InformationalContentActivity.this, Const.CategoryConfig).getBoolean(
							"ac.comment_need_login")) {
						// 如果评论需要登录
						if (!TextUtils.isEmpty(SharedPreferencesKit.getString(InformationalContentActivity.this, Const.SP_KEY_USER_ID))) {

							commiComment();
						} else {
							ToastKit.showShort(InformationalContentActivity.this, Const.UN_LOGIN_ALERT);
						}
					} else {
						// 如果评论不需要登录
						commiComment();
					}
				} catch (JSONException e1) {
					Log.e(TAG, e1.getMessage(), e1);
				}
				writeComment.setText("");
				mPopupWindow.dismiss();
			}

		});
		// 创建一个PopupWindow
		// 参数1：contentView 指定PopupWindow的内容
		// 参数2：width 指定PopupWindow的width
		// 参数3：height 指定PopupWindow的height
		mPopupWindow = new PopupWindow(popupWindow, android.view.ViewGroup.LayoutParams.MATCH_PARENT,
				android.view.ViewGroup.LayoutParams.WRAP_CONTENT);
		// 必须设置背景
		mPopupWindow.setBackgroundDrawable(new BitmapDrawable());
		// 设置点击其他地方 就消失 (只设置这个，没有效果)

		mPopupWindow.setOutsideTouchable(true); /* 设置触摸外面时消失 */

		mPopupWindow.setFocusable(true);
		mPopupWindow.setSoftInputMode(PopupWindow.INPUT_METHOD_NEEDED);
		mPopupWindow.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
	}

	/**
	 * 提交评论
	 * 
	 * @author lkx Created at 2015-10-24 上午9:38:41
	 */
	private void commiComment() {
		ApiParam param = ApiParam.create();
		param.addParam("id", newsId);
		param.addParam("type", type);
		if (!TextUtils.isEmpty(writeComment.getText().toString())) {
			param.addParam("content", writeComment.getText().toString());
			Api.post("comment/submit", param, new ApiCallback(InformationalContentActivity.this) {

				@Override
				public void handleSuccess(ApiResult result) {
					mPopupWindow.dismiss();
					// 评论完成之后重新获取评论数
					// getContentData();
					// initData(newsId);
					if (result.getCode() == 100) {
						// if (newCommentAdapter == null ||
						// newCommentAdapter.getCount() == 0) {
						// newCommentAdapter = new CommentAdapter(mContext);
						// newCommentListview.setAdapter(newCommentAdapter);
						// }
						// newCommentAdapter.addOneData(result.getData());
						// ListViewKit.setListViewHeightBasedOnChildren(newCommentListview);

						// TODO 为何这样呢！！！
						page = 1;
						getNewComment();
					} else {
						ToastKit.showShort(mContext, "评论失败");
					}
				}

				@Override
				public void handleFailure(Exception e, String msg) {

				}
			}, InformationalContentActivity.this);
		} else {
			ToastKit.showShort(InformationalContentActivity.this, "评论不能为空");
		}
	}

	/**
	 * 显示pupop
	 * 
	 * @author lkx Created at 2015-10-16 下午3:44:17
	 */
	private void showPupop() {

		if (mPopupWindow.isShowing()) {
			mPopupWindow.dismiss();
		} else {
			mPopupWindow.showAtLocation(findViewById(R.id.information), Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0, 0);
		}

	}

	/**
	 * 初始化设置字体大小popu
	 * 
	 * @author lkx Created at 2015-10-16 下午5:42:03
	 */
	@SuppressWarnings("deprecation")
	private void initCotentSizePupoVindow() {
		LayoutInflater layoutInflater = LayoutInflater.from(this);
		View popupWindow = layoutInflater.inflate(R.layout.infox_content_set_textsize_pupo, null);
		mPopupWindow = new PopupWindow(popupWindow, android.view.ViewGroup.LayoutParams.MATCH_PARENT,
				android.view.ViewGroup.LayoutParams.WRAP_CONTENT);
		// 必须设置背景
		mPopupWindow.setBackgroundDrawable(new BitmapDrawable());
		// 设置点击其他地方 就消失 (只设置这个，没有效果)
		mPopupWindow.setOutsideTouchable(true); /* 设置触摸外面时消失 */

		CheckBox nightType = (CheckBox) popupWindow.findViewById(R.id.nightType);
		SeekBar seekBar = (SeekBar) popupWindow.findViewById(R.id.seekBar);
		RadioGroup radioGroup = (RadioGroup) popupWindow.findViewById(R.id.radioGroup);
		TextView btnFinish = (TextView) popupWindow.findViewById(R.id.btnFinish);
		btnFinish.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View arg0) {
				mPopupWindow.dismiss();
			}
		});

		fontSize = SharedPreferencesKit.getString(this, Const.SP_TEXTSIZE);
		if (!TextUtils.isEmpty(fontSize)) {
			if ("max".equalsIgnoreCase(fontSize)) {
				radioGroup.check(R.id.textBig);
			} else if ("min".equalsIgnoreCase(fontSize)) {
				radioGroup.check(R.id.textSamll);
			} else if ("max_big".equalsIgnoreCase(fontSize)) {
				radioGroup.check(R.id.textVeryBig);
			} else if ("mid".equalsIgnoreCase(fontSize)) {
				radioGroup.check(R.id.textNormal);
			}
		}
		radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
			@Override
			public void onCheckedChanged(RadioGroup group, int checkedId) {
				if (checkedId == R.id.textVeryBig) {
					fontSize = "max_big";
				} else if (checkedId == R.id.textBig) {
					fontSize = "max";
				} else if (checkedId == R.id.textNormal) {
					fontSize = "mid";
				} else if (checkedId == R.id.textSamll) {
					fontSize = "min";
				}
				if (!TextUtils.isEmpty(SharedPreferencesKit.getString(InformationalContentActivity.this, Const.SP_KEY_USER_ID))) {
					// 如果用户已经登录，将设置信息提交
					Api.post("me/setting", ApiParam.create().addParam("key", Const.SP_TEXTSIZE).addParam("value", fontSize),
							new EmptyApiCallback(InformationalContentActivity.this, true), InformationalContentActivity.this);
				}
				SharedPreferencesKit.putString(InformationalContentActivity.this, Const.SP_TEXTSIZE, fontSize);
				renderWebView();
			}
		});
		int screenBrightness = 100;
		try {
			screenBrightness = Settings.System.getInt(getContentResolver(), Settings.System.SCREEN_BRIGHTNESS);
		} catch (SettingNotFoundException e1) {
			e1.printStackTrace();
		}
		seekBar.setProgress(screenBrightness);
		seekBar.setMax(255);
		seekBar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {

			@Override
			public void onStopTrackingTouch(SeekBar seekBar) {
			}

			@Override
			public void onStartTrackingTouch(SeekBar seekBar) {
			}

			@Override
			public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
				if (progress < 30) {
					seekBar.setProgress(30);
				}
				Settings.System.putInt(getContentResolver(), Settings.System.SCREEN_BRIGHTNESS, progress);
			}
		});

		boolean isNight = SharedPreferencesKit.getBoolean(this, Const.SP_NIGHTStyle, false);
		nightType.setChecked(isNight);
		nightType.setOnCheckedChangeListener(new OnCheckedChangeListener() {
			@Override
			public void onCheckedChanged(CompoundButton arg0, final boolean value) {
				SharedPreferencesKit.putBoolean(InformationalContentActivity.this, Const.SP_NIGHTStyle, value);
				renderWebView();
				// 如果用户已经登录，将设置信息提交
				if (!TextUtils.isEmpty(SharedPreferencesKit.getString(InformationalContentActivity.this, Const.SP_KEY_USER_ID))) {
					Api.post("me/setting", ApiParam.create().addParam("key", Const.SP_NIGHTStyle).addParam("value", String.valueOf(value)),
							new EmptyApiCallback(InformationalContentActivity.this, true), InformationalContentActivity.this);
				}
			}
		});
	}

	/**
	 * 初始化分享弹窗
	 * 
	 * @author lkx Created at 2015-10-22 下午8:25:45
	 */
	@SuppressLint("InflateParams")
	@SuppressWarnings("deprecation")
	private void initSharePupoVindow() {

		LayoutInflater layoutInflater = LayoutInflater.from(this);
		View popupWindow = layoutInflater.inflate(R.layout.infox_activity_content_share_popu, null);

		mPopupWindow = new PopupWindow(popupWindow, android.view.ViewGroup.LayoutParams.MATCH_PARENT,
				android.view.ViewGroup.LayoutParams.WRAP_CONTENT);
		// 必须设置背景
		mPopupWindow.setBackgroundDrawable(new BitmapDrawable());
		// 设置点击其他地方 就消失 (只设置这个，没有效果)

		mPopupWindow.setOutsideTouchable(true); /* 设置触摸外面时消失 */
		popupWindow.findViewById(R.id.shareToWeixin).setOnClickListener(this);
		popupWindow.findViewById(R.id.shareToFriendCircle).setOnClickListener(this);
		popupWindow.findViewById(R.id.shareToMessage).setOnClickListener(this);
		popupWindow.findViewById(R.id.shareToQQ).setOnClickListener(this);
		popupWindow.findViewById(R.id.shareToWeb).setOnClickListener(this);
		popupWindow.findViewById(R.id.shareEmail).setOnClickListener(this);
		popupWindow.findViewById(R.id.transpond).setOnClickListener(this);
		popupWindow.findViewById(R.id.shareCopyLink).setOnClickListener(this);
		popupWindow.findViewById(R.id.cancle).setOnClickListener(this);
	}

	@Override
	protected void onResume() {
		if (!isFirstLoading) {
			initData(newsId);
		}
		super.onResume();
	}

	/**
	 * scrollView监听
	 * 
	 * @author lkx Created at 2015-11-6 下午9:34:21
	 * @version 1.0
	 */
	private class TouchListenerImpl implements OnTouchListener {
		@Override
		public boolean onTouch(View view, MotionEvent motionEvent) {
			switch (motionEvent.getAction()) {
			case MotionEvent.ACTION_DOWN:

				break;
			case MotionEvent.ACTION_MOVE:
				int scrollY = view.getScrollY();
				int height = view.getHeight();
				int scrollViewMeasuredHeight = scrollview.getChildAt(0).getMeasuredHeight();
				// if (scrollY == 0) {
				// Log.d("滑动到了顶端 view.getScrollY()=" + scrollY);
				// }
				if ((scrollY + height) == scrollViewMeasuredHeight) {
					// 滑动到底部
					page++;
					getNewComment();
				}
				break;

			default:
				break;
			}
			return false;
		}

	}

	;
}
